import { basicDictSlotList,basicSlotDialogList,basicSlotQaList,basicDictSysList,basicDictList,slotList,slotAddModification,wordTroughDelete,dictionaryList,loadDictItemsForJson,querySlotInformation } from '@/services/basiccapacity';

export default {
  namespace:'wordTroughManage',

  state: {
  
  },
  effects: {
    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(slotList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchb({ payload, callback }, { call, put }) {
      const response = yield call(slotAddModification, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchc({ payload, callback }, { call, put }) {
      const response = yield call(wordTroughDelete, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchd({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(dictionaryList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetche({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(loadDictItemsForJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchf({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(querySlotInformation, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicDictSysList({ payload, callback }, { call, put }) { // 系统实体列表
      const response = yield call(basicDictSysList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicDictList({ payload, callback }, { call, put }) { // 自定义实体列表
      const response = yield call(basicDictList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicDictSlotList({ payload, callback }, { call, put }) { // 实体管理 使用中词槽列表
      const response = yield call(basicDictSlotList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicSlotDialogList({ payload, callback }, { call, put }) { // 词槽管理 词槽使用中的多轮列表
      const response = yield call(basicSlotDialogList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicSlotQaList({ payload, callback }, { call, put }) { // 词槽管理 词槽使用中的知识点列表
      const response = yield call(basicSlotQaList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
       
      };
    },
  },
};
